//
//  ST_RegisterStepMonitor.swift
//  btvideo
//
//  Created by Jason on 2021/12/8.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import SwiftyUserDefaults


class ST_RegisterStepMonitor:NSObject{
    
    /**
     1选择登录方式
     2输入手机号
     3输入验证码
     4填写个人资料
     5推荐附近小姐姐
     6选择交友模式
     7选择感情关系
     8选择偏爱特质大类
     9选择偏爱特质子类
     10推荐符合要求用户
     11认证门槛页
     12支付门槛成功
     */
    private let stepClasses = [ST_SimilarLoginViewController.self,ST_BTPhoneNumberController.self,ST_BTCaptchaController.self,ST_QuickStartProfileController.self,ST_NearbyGirlsRegisterController.self, ST_RegisterFriendForViewController.self, ST_SeekPreferenceViewController.self, ST_ParentStyleRegisterController.self, ST_ChildStyleRegisterController.self, ST_RecommendStyleRegisterViewController.self, ST_TicketViewController.self, ST_StartHomeViewController.self]
    
}


extension ST_RegisterStepMonitor{
    
    func report(fromController:UIViewController){
        
        let fromClass = NSStringFromClass(type(of: fromController))
        
        if let idx = stepClasses.firstIndex(where: { fromClass == NSStringFromClass($0) })?.string.int{
            
            let index = (idx + 1).string
            
            TIANSession(requestUrl: idx < 3 ? PH.registerSetpBeforeLogApi : PH.registerSetpAfterLogApi, parameters: ["type":index,"register_device_id":Defaults[.registerID]]).wrap_response_data().retry().subscribe(onNext: { _ in
                
            }).disposed(by: rx.disposeBag)
            
        }
        
    }
    
}
